package leetcode_数与位._01数字的位操作;

/**
 * @author yzh
 * @data 2021/3/24 20:26
 * 数字的补数
 * 思路：
 *   例如 5，101 ^ 111 = 10
 *   所以先得出 111
 */
public class _476_数字的补数 {
    public static void main(String[] args) {
        int n = 5;
        System.out.println(-1);
    }

    public int findComplement(int num) {
        int tem = num, res = 0;
        while (tem > 0) {
            res = (res << 1) + 1;
            tem = tem >> 1;
        }
        return num ^ res;
    }
}
